import { _decorator, Component, JsonAsset, misc, Node } from 'cc';
import { BulletController } from './BulletController';
import { ResourceUtil } from '../AshFramework/Utils/ResourceUtil';
const { ccclass, property } = _decorator;

@ccclass('BulletController_Enemy')
export class BulletController_Enemy extends BulletController {
    fire(bulletName: string, dirX: number, dirY: number) {
        this.Name = bulletName;
        this.DirX = dirX;
        this.DirY = dirY;

        ResourceUtil.LoadJson("EnemyData").then((jsonAsset: JsonAsset) => {
            const json = jsonAsset.json[this.Name];
            this.Harm = json.harm;
        })

        let angleRadians = Math.atan2(this.DirY, this.DirX);
        let angleDegrees = misc.radiansToDegrees(angleRadians);

        this.node.angle = angleDegrees;
    }
}


